#ifndef HSE_WINSERVER_H
#define HSE_WINSERVER_H

#include <stdio.h>
#include <winsock2.h>
#include <vector>
#include "hse_common.h"
#include "hse_types.h"
#include "search.h"
#include "search_engine.h"

namespace hse {

class WinServer {
public:
	WinServer() {}
	void Start(u_short port);
	~WinServer() { if (search_engine_ != NULL) delete search_engine_;}
private:
	SearchEngine *search_engine_;

	void HandleRequest(SOCKET sock, sockaddr_in addr);
	void HandleHome(SOCKET sock);
	void HandleSearch(SOCKET sock, const char* query);
	inline void WinServer::Send404(SOCKET sock);
	void WinServer::HandleViewDoc(SOCKET sock, int doc_id);
	
	DISALLOW_COPY_AND_ASSIGN(WinServer);
};

}

#endif